home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / gst-python / 0.10 / examples / cp.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  1.6 KB  |  46 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import sys
  5. import gobject
  6. gobject.threads_init()
  7. import pygst
  8. pygst.require('0.10')
  9. import gst
  10. mainloop = gobject.MainLoop()
  11.  
  12. def on_eos(bus, msg):
  13.     mainloop.quit()
  14.  
  15.  
  16. def filter(input, output):
  17.     '''A GStreamer copy pipeline which can add arbitrary filters'''
  18.     bin = gst.parse_launch('filesrc name=source ! ' + 'filesink name=sink')
  19.     filesrc = bin.get_by_name('source')
  20.     filesrc.set_property('location', input)
  21.     filesink = bin.get_by_name('sink')
  22.     filesink.set_property('location', output)
  23.     bus = bin.get_bus()
  24.     bus.add_signal_watch()
  25.     bus.connect('message::eos', on_eos)
  26.     bin.set_state(gst.STATE_PLAYING)
  27.     
  28.     try:
  29.         mainloop.run()
  30.     except KeyboardInterrupt:
  31.         pass
  32.  
  33.     bin.set_state(gst.STATE_NULL)
  34.  
  35.  
  36. def main(args):
  37.     '''A GStreamer based cp(1) with stats'''
  38.     if len(args) != 3:
  39.         print 'usage: %s source dest' % sys.argv[0]
  40.         return -1
  41.     return filter(args[1], args[2])
  42.  
  43. if __name__ == '__main__':
  44.     sys.exit(main(sys.argv))
  45.  
  46.